import { Badge, Button, Card, Descriptions } from "antd";
import React, { useEffect, useState } from "react";
import { reqGetHospitalShow } from "@api/hospital/hospitalList/hospitalList";
import { Link, useParams } from "react-router-dom";
import { ReqGetHospitalShowResponse } from "@/api/hospital/hospitalList/model/hospitalTypes";

export default function HospitalShow() {
  //获取 url 的 id 参数
  let { id } = useParams();
  //声明状态
  let [hospital, setHospital] = useState<ReqGetHospitalShowResponse>();
  //生命周期钩子
  useEffect(() => {
    //发送请求
    let getInfo = async () => {
      let result = await reqGetHospitalShow(id as string);
      //更新状态
      setHospital(result);
    };
    getInfo();
  }, []);

  return (
    <Card>
      <Descriptions title="基本信息" bordered>
        <Descriptions.Item label="医院名称" labelStyle={{width: 120}}>
          {hospital?.hospital.hosname}
        </Descriptions.Item>
        <Descriptions.Item label="医院logo" span={2}>
          <img
            width="60"
            src={hospital?.hospital.logoData ? "data:image/png;base64," + hospital?.hospital.logoData : ''}
          />
        </Descriptions.Item>
        <Descriptions.Item label="医院编码">
          {hospital?.hospital.hoscode}
        </Descriptions.Item>
        <Descriptions.Item label="医院地址" span={2}>
          {hospital?.hospital.param.fullAddress}
        </Descriptions.Item>

        <Descriptions.Item label="坐车路线" span={3}>
          {hospital?.hospital.route}
        </Descriptions.Item>
        <Descriptions.Item label="医院简介" span={3}>
          {hospital?.hospital.intro}
        </Descriptions.Item>
      </Descriptions>
      <div className="h-20"></div>
      <Descriptions
        title="预约规则信息
"
        bordered
      >
        <Descriptions.Item label="预约周期">
          {hospital?.bookingRule.cycle}
        </Descriptions.Item>
        <Descriptions.Item label="放号时间" span={2}>
          {hospital?.bookingRule.releaseTime}
        </Descriptions.Item>
        <Descriptions.Item label="停挂时间">
          {hospital?.bookingRule.stopTime}
        </Descriptions.Item>
        <Descriptions.Item label="退号时间" span={2}>
          {hospital?.bookingRule.quitTime}
        </Descriptions.Item>

        <Descriptions.Item label="预约规则" span={3}>
          {hospital?.bookingRule.rule.map((item, index) => {
            return <p key={index}>{item}</p>
          })}
        </Descriptions.Item>
      </Descriptions>

      <div className="h-20"></div>
      <Link to="/syt/hospital/hospitalList"><Button>返回</Button></Link>
    </Card>
  );
}
